package com.crr.controller;

import com.crr.common.bean.ResultBean;
import com.crr.common.controller.BaseController;
import com.crr.service.OrderService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/v1")
@Api(tags = "下单")
public class OrderController extends BaseController {

    @Autowired
    OrderService orderService;

    @ApiOperation("抢购")
    @GetMapping("/order")
    public ResultBean save(int userId, int goodsId){
       int rs=orderService.save(userId,goodsId);
        return rs==1?success("抢购成功"):fail("抢购失败");
    }


    @ApiOperation("测试")
    @GetMapping("/order/test")
    public ResultBean get(){
        orderService.test();
        return success("ok");
    }
}